package com.wang.controller;

import com.wang.pojo.LoginParam;
import com.wang.service.LoginService;
import com.wang.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private LoginService loginService;

    @PostMapping
    public Result login(@RequestBody LoginParam loginParam) {
        return loginService.login(loginParam);
    }

    @PostMapping("/register")
    public Result register(@RequestBody LoginParam loginParam) {
        return loginService.register(loginParam);
    }

    @GetMapping("/logout")
    public Result logout(@RequestHeader("token") String token) {
        return loginService.logout(token);
    }
}
